<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>jQueryEJS example</title>
	<style type="text/css">
		ejs {
			display: none;
		}
	</style>
</head>
<body>
    <div>
        <ul id="dataContainer">
            <ejs data-id="dataTemplate">
                <% var total = 0; for (var i = 0; i < data.goodsList.length; i++) { total += data.goodsList[i].price; %>
                <li>
                    <span><%= data.goodsList[i].id %></span>
                    <span><%= data.goodsList[i].name %></span>
                    <span><%= data.goodsList[i].price %>元</span>
                    <span><%= EJS.localDate(data.goodsList[i].time) %></span>
                </li>
                <% } %>
                <li>共<%= data.goodsCount %>个，一共<%= total %>元</li>
            </ejs>
        </ul>
    </div>
    <script src="jquery.min.js"></script>
    <script src="jquery.ejs.js"></script>
    <script>
    $.ejs();
    var json = {goodsCount: 3, goodsList: [{id: "1", name: "白萝卜", price: 5.4, time: 1471534991878 }, {id: "2", name: "花生", price: 7.25, time: 1471534991878 }, {id: "3", name: "花菜", price: 4.85, time: 1471534991878 }] };
    $('#dataContainer').ejs('dataTemplate', {data: json });
    </script>
</body>
</html>
